﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlBaoCaoTienDoThucHienChiTieu.ascx.cs" Inherits="UserControl_ControlBaoCaoTienDoThucHienChiTieu" %>

<%@ Register assembly="DevExpress.Web.ASPxEditors.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>

<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dxwpg" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2.Export, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.XtraPivotGrid.Web" tagprefix="dxpgw" %>




<script type="text/javascript">
    function pageLoad() {

        //Ngày
        $(function () {
            $("#<%= txtFromDate.ClientID %>").datePicker(
	                {
	                    clickInput: true,
	                    startDate: '01/01/1970'
	                }
	                );
        });

        $("#<%= txtFromDate.ClientID %>").bind(
		            'dpClosed', function (e, selectedDates) {
		                var d = selectedDates[0];
		                if (d) {
		                    d = new Date(d);
		                    $("#<%= txtToDate.ClientID %>").dpSetStartDate(d.addDays(0).asString());
		                }
		            }
	                    );

        $(function () {
            $("#<%= txtToDate.ClientID %>").datePicker(
	                {
	                    clickInput: true

	                }
	                );
        });

        $("#<%= txtToDate.ClientID %>").bind(
		           'dpClosed', function (e, selectedDates) {
		               var d = selectedDates[0];
		               if (d) {
		                   d = new Date(d);
		                   $("#<%= txtFromDate.ClientID %>").dpSetEndDate(d.addDays(0).asString());
		               }
		           }
	            );

        $("#<%= imgBtnAdd.ClientID %>").click(function () {
           
                $.blockUI({
                    message: '<h1>Xin vui lòng chờ xử lý</h1>',
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#f00',
                        opacity: .5,
                        color: '#fff'
                    }
                });
            
        });
        $("#<%= imgBtnSave.ClientID %>").click(function () {
            $.blockUI({
                message: '<h1>Xin vui lòng chờ xử lý</h1>',
                css: {
                    border: 'none',
                    padding: '15px',
                    backgroundColor: '#f00',
                    opacity: .5,
                    color: '#fff'
                }
            });
            setTimeout($.unblockUI, 5000);
        });
        $("#<%= ImgBtnPivot.ClientID %>").click(function () {
            $.blockUI({
                message: '<h1>Xin vui lòng chờ xử lý</h1>',
                css: {
                    border: 'none',
                    padding: '15px',
                    backgroundColor: '#f00',
                    opacity: .5,
                    color: '#fff'
                }
            });
            setTimeout($.unblockUI, 5000);
        });

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {
            $.unblockUI();
        }

    }

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="imgBtnSave" />
<asp:PostBackTrigger ControlID="ImgBtnPivot" />
</Triggers>
    <ContentTemplate>
     <div class="direct_container_right_titletop">
                     Báo cáo tiến độ thực hiện chỉ tiêu
                </div>
                 <hr />
                <!-- Button chuc nang-->
                <div class="direct_container_main">
                    <asp:ImageButton ID="imgBtnAdd" CausesValidation="false" onclick="imgBtnAdd_Click" ToolTip="Lấy dữ liệu"  ImageUrl="~/Images/Document.png" Width="32px" Height="32px" runat="server" />
                    <asp:ImageButton ID="imgBtnSave" onclick="imgBtnSave_Click" CausesValidation="false" ToolTip="Xuất ra file excel dạng thường" ImageUrl="~/Images/download.png" Width="32px" Height="32px" runat="server" />
                    <asp:ImageButton ID="ImgBtnPivot" onclick="ImgBtnPivot_Click" CausesValidation="false" ToolTip="Xuất ra file excel dạng pivot" ImageUrl="~/Images/rename.png" Width="32px" Height="32px" runat="server" />
                    
                </div>
                <!-- End Button chuc nang-->
                <div class="direct_container_main">
                    <table>
                        <tr>
                            <td>Trình dược viên</td>
                            <td>
                                <asp:DropDownList ID="drlTDV" runat="server" Width="200">
                                </asp:DropDownList>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                            
                        <tr>
                            <td colspan="4">
                                <asp:RadioButton GroupName="select" ID="RMonth" Checked="true" Text="Xem theo quý" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>Chọn quý</td>
                            <td>
                                <asp:DropDownList ID="DropMonthy" runat="server" Width="200">
                                </asp:DropDownList>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <asp:RadioButton GroupName="select" ID="RDate" Text="Xem theo ngày" runat="server"/>
                            </td>
                        </tr>
                        <tr>
                            <td>Từ ngày</td>
                            <td>  
                                <asp:TextBox ID="txtFromDate" runat="server" Width="200"></asp:TextBox> 
                                                                  
                            </td>
                            <td>Đến Ngày</td>
                            <td>
                                <asp:TextBox ID="txtToDate" runat="server" Width="200"></asp:TextBox>
                                    
                            </td>
                        </tr>
                            
                        
                    </table>  
                    <hr />
                       <div>
                             <asp:RadioButtonList RepeatDirection="Horizontal" RepeatColumns="5" AutoPostBack="true" ID="RadioButtonList1" runat="server" 
                                         onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
                                <asp:ListItem Selected="True" Text="Báo cáo doanh số khách hàng của Fimex" Value="0"></asp:ListItem>
                                <asp:ListItem Text="Báo cáo doanh số của DKSH" Value="1"></asp:ListItem>
                                <asp:ListItem Text="Báo cáo doanh số của NMD" Value="2"></asp:ListItem>
                            </asp:RadioButtonList>
                    </div>                 
                    
                </div>
                <!-- End Button chuc nang-->
                
                <div style="overflow:scroll; width:100%">
        <dxpgw:ASPxPivotGridExporter ID="ASPxPivotGridExporter1" ASPxPivotGridID="ASPxPivotGrid1" runat="server" Width="100%">
        </dxpgw:ASPxPivotGridExporter>
        <dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1"  runat="server">
                 <Fields>
                <dxwpg:PivotGridField ID="PivotInvoiceID" Area="FilterArea"  AreaIndex="0" 
                         Caption="Mã hóa đơn" FieldName="InvoiceID">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotInvDate" Area="FilterArea"  AreaIndex="1" 
                         Caption="Ngày hóa đơn" FieldName="InvDate">
                </dxwpg:PivotGridField>
                
                <dxwpg:PivotGridField ID="PivotSubChannelName" Area="FilterArea"  AreaIndex="3" 
                         Caption="Sub Channel" FieldName="SubChannelName">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotProvince" Area="FilterArea"  AreaIndex="4" 
                         Caption="Tỉnh/Thành" FieldName="Province">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotTown" Area="FilterArea"  AreaIndex="5" 
                         Caption="Quận/Huyện" FieldName="Town">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotRegion" Area="FilterArea"  AreaIndex="6" 
                         Caption="Region" FieldName="Region">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotArea" Area="FilterArea"  AreaIndex="7" 
                         Caption="Area" FieldName="Area">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotLoaiHD" Area="FilterArea"  AreaIndex="8" 
                         Caption="Loại HĐ" FieldName="LoaiHD">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotTenVT" Area="FilterArea"  AreaIndex="9" 
                         Caption="Tên SKU" FieldName="TenVT">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotQuantity" Area="FilterArea"  AreaIndex="10" 
                         Caption="Số lượng" FieldName="Quantity">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotDGLE" Area="FilterArea"  AreaIndex="11" 
                         Caption="Đơn giá bán" FieldName="DGLE">
                </dxwpg:PivotGridField>
                
                
                <dxwpg:PivotGridField ID="PivotChannelSKU" Area="FilterArea"  AreaIndex="15" 
                         Caption="Channel(SKU)" FieldName="Channel(SKU)">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotGroupSKU" Area="FilterArea"  AreaIndex="16" 
                         Caption="Group(SKU)" FieldName="Group(SKU)">
                </dxwpg:PivotGridField>
                
                 <dxwpg:PivotGridField ID="PivotDistributor" Area="FilterArea"  AreaIndex="18" 
                         Caption="Nhà phân phối" FieldName="Distributor">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotHeadOffice" Area="RowArea"  AreaIndex="0" 
                         Caption="Head Office" FieldName="HeadOffice">
                </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="PivotGridField1" Area="RowArea"  AreaIndex="1" 
                         Caption="Channel" FieldName="Channel">
                </dxwpg:PivotGridField>
               

                <dxwpg:PivotGridField ID="PivotThanhTienNoCKNoVAT" Area="DataArea"  AreaIndex="0" 
                         Caption="Thành tiền (chưa CK)" CellFormat-FormatString="{0:###,###.###}" CellFormat-FormatType="Numeric" FieldName="TTTDV">
                </dxwpg:PivotGridField>
                 
                 <dxwpg:PivotGridField ID="PivotTT" Area="DataArea"  AreaIndex="1" 
                         Caption="Thành tiền (CK)" CellFormat-FormatString="{0:###,###.###}" CellFormat-FormatType="Numeric" FieldName="TT">
                </dxwpg:PivotGridField>
                <dxwpg:PivotGridField ID="PivotThanhTienCKVAT" Area="DataArea"  AreaIndex="2" CellFormat-FormatString="{0:###,###.###}" CellFormat-FormatType="Numeric" 
                         Caption="Thành tiền (CK+VAT)" FieldName="TTV">
                </dxwpg:PivotGridField>

                </Fields>
                <OptionsPager Visible="False">
               </OptionsPager>
        </dxwpg:ASPxPivotGrid>
    </div>
    </ContentTemplate>
</asp:UpdatePanel>